home *** CD-ROM | disk | FTP | other *** search
Wrap
Oberon Document | 1996-09-29 | 3.2 KB | 97 lines | [ BINA/hDmp]
Documents.StdDocumentDesc Documents.DocumentDesc Containers.ViewDesc Views.ViewDesc Stores.StoreDesc Documents.ModelDesc Containers.ModelDesc Models.ModelDesc Stores.ElemDesc TextViews.StdViewDesc TextViews.ViewDesc TextModels.StdModelDesc TextModels.ModelDesc TextModels.AttributesDesc Helvetica (* This module deomstrates a simple "HelloWorld" program using the Mac toolbox calls with Oberon. This is a complete module by itself and can be compiled and run as is. *) MODULE MactechHelloWorld; IMPORT SYSTEM, RM := MacResourceMgr, QD := MacQuickDraw, FS := MacFileMgr, MacFontMgr, MacWindowMgr, MN := MacMenuMgr, TE := MacTextEdit, DL := MacDialogMgr, MT := MacTypes, EV := MacEventMgr, ME := MacMemoryMgr, OS := MacOSUtils; gWindowRect : QD.Rect; gWindowRefCon : LONGINT; gWindow : MacWindowMgr.WindowPtr; (* InitMac initializes the Mac ToolBox *) PROCEDURE InitMac; BEGIN QD.InitGraf(QD.globals.thePort); (* The QuickDraw Globals are Oberon Variables *) MacFontMgr.InitFonts; MacWindowMgr.InitWindows; MN.InitMenus; TE.TEInit; DL.InitDialogs(0); QD.InitCursor; END InitMac; (* Create a new window and display it *) PROCEDURE MakeWindow; windowTitle : MT.Str255; temp : ARRAY 256 OF CHAR; behind : MacWindowMgr.WindowPtr; (* behind flag in NewWindow *) BEGIN temp := "MacTech Magazine"; behind := SYSTEM.VAL(MacWindowMgr.WindowPtr, -1); MT.SetStr255(windowTitle, temp); QD.SetRect(gWindowRect, 50, 200, 300, 400); gWindow := MacWindowMgr.NewWindow(NIL, gWindowRect, windowTitle, TRUE, MacWindowMgr.noGrowDocProc, behind, TRUE, gWindowRefCon); MacWindowMgr.ShowWindow(gWindow); END MakeWindow; (* Draw our "HelloWorld" string in the window *) PROCEDURE HelloWorld; oldPort : QD.GrafPtr; helloWorld : MT.Str255; temp : ARRAY 256 OF CHAR; BEGIN temp := "Hello World"; MT.SetStr255(helloWorld, temp); QD.GetPort(oldPort); QD.SetPort(gWindow); QD.TextSize(26); QD.MoveTo(25, 100); QD.DrawString(helloWorld); QD.SetPort(oldPort); END HelloWorld; (* Create our Do command. Can be run inside the Oberon environment. *) PROCEDURE Do*; BEGIN InitMac; MakeWindow; HelloWorld; REPEAT UNTIL EV.Button(); MacWindowMgr.DisposeWindow(gWindow); END Do; (* Main program begin. If we are to compile and link this as a separate application then this section should make a single call to Do; *) BEGIN END MactechHelloWorld. TextControllers.StdCtrlDesc TextControllers.ControllerDesc Containers.ControllerDesc Controllers.ControllerDesc TextRulers.StdRulerDesc TextRulers.RulerDesc TextRulers.StdStyleDesc TextRulers.StyleDesc TextRulers.AttributesDesc Helvetica Documents.ControllerDesc